package model;

import java.io.File;
import java.text.MessageFormat;

import managerService.ManagerSystem;


public class Type {

	private int id;
	private String name;
	
	public Type(String name){
		this.name = name;
	}

	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public String toXML(){
		return MessageFormat.format(
				"<type>\n\t<id>{0}</id>\n\t<name>{1}</name>\n</type>", 
				this.getId(), this.getName());
	}

	public void toFile(){
		System.out.println(ManagerSystem.getService().getTypeXMLPath());
		Singleton.toFile(this.toXML(),
				ManagerSystem.getService().getTypeXMLPath() + File.separator + this.name + ".xml");
	}
	
	@Override
	public String toString(){
		return this.name;
	}
}
